package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqSettleAccountBalance;
import com.ruoyi.hqfinance.domain.vo.HqSettleAccountBalanceVo;
import com.ruoyi.hqfinance.service.HqSettleAccountBalanceService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/settleAccountBalance")
@Api(tags = "总部财务-结算账户余额查询")
public class HqSettleAccountBalanceController {
    @Autowired
    private HqSettleAccountBalanceService hqSettleAccountBalanceService;

    @ApiOperation("搜索")
    @PostMapping("/search")
    public R search(@RequestBody HqSettleAccountBalanceVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getTimeType() == null){
            return R.fail("请传入查询所需的时间参数！");
        }
        List<HqSettleAccountBalance> hqSettleAccountBalances = hqSettleAccountBalanceService.search(vo);
        if (hqSettleAccountBalances == null || hqSettleAccountBalances.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(hqSettleAccountBalances));
        }
    }
}
